package com.fysports.web.controller;

import com.jfinal.plugin.activerecord.Db;
import com.fysports.web.kit.commons.CookiesKit;
import com.fysports.web.kit.commons.PathBizKit;
import com.fysports.web.model.system.SystemUser;
import com.fysports.web.model.user.BizUser;
import com.fysports.web.module.core.DefaultModuleBuilder;
import com.fysports.web.module.core.IModuleFactory;


/**
 * path:main 首页
 * Created by konbluesky
 * Date : 14-7-31 下午3:08
 * Project : JdmData_WebServer
 */
public class IndexController extends AbstractBaseController {
    IModuleFactory imf = new DefaultModuleBuilder();


    public void index() {
        imf.create(this);
        execute();
        setAttr("boxcount", 10);
        setAttr("usercount", Db.queryLong("select count(1) from "+ BizUser.dao.getTable().getName()));
        render(PathBizKit.getPageAdminPath("/index.ftl"));
    }


    /**
     * 我的信息
     */
    public void profile() {
        imf.create(this);
        execute();

        String cookie = getCookie(CookiesKit.COOKIES_AUTHMARK);
        //取出cookie中的useruuid
        CookiesKit.CookieVO cvo = CookiesKit.decodeCookieAuthToken(cookie);
        SystemUser su = SystemUser.dao.searchFirst(SystemUser.COL_UUID, cvo.getUserid());
        setAttr("m", su);
        render(PathBizKit.getPageAdminPath("myprofile.ftl"));
    }

}
